<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <!-- <button>按钮</button> -->

    <span></span>

</body>

<script>
    var bu = document.querySelector('button');
    var span = document.querySelector('span');


    var i = 5;
    span.innerHTML = '页面还有' + (i--) + '秒跳转';

    function s() {
        span.innerHTML = '页面还有' + (i--) + '秒跳转';
        if (i <= 0) {
            location.href = 'https://www.baidu.com/';
        }
    }
    setInterval(s, 1000);

    /* bu.onclick = function() {
        console.log(location);
        location.href = 'https://www.baidu.com/';

    } */
</script>


</html>